module.exports = function($scope,$state,$resource,$modal){
    /* 分页
        * ========================================= */
        $scope.maxSize = 5;             //最多显示多少个按钮
        $scope.currentPage = 1;      //当前页码
        $scope.itemsPerPage = 10         //每页显示几条
            /* 分页
        * ========================================= */
        $scope.maxSize = 5;             //最多显示多少个按钮
        $scope.currentPage2 = 1;      //当前页码
        $scope.itemsPerPage2 = 10         //每页显示几条
        $scope.searchform = {};
        $scope.information=function(info){
         $state.go('app.equipmentMessageDetailInformation',{'geid':info.code1,'show':'show'});
 }
         $scope.information2=function(info){

             $state.go('app.equipmentMessageHotelDetailInformation',{'geid':info.code1});
                 
       
   }
         function date2str(d) {
            if (d ===undefined) {
                return "";
            }
            var month = (d.getMonth() + 1).toString();
            var day = d.getDate().toString();
            if (month.length == 1) month = '0' + month;
            if (day.length == 1) day = '0' + day;
            return d.getFullYear() + month + day;
        }

        $scope.date = {
            // 'lable': date2str2(new Date()),
            //'lable': new Date(),
            //'value': date2str(new Date()),
            'opened': false
        }


         $scope.dateOpen = function ($event, item) {
            $event.preventDefault();
            $event.stopPropagation();
            item.opened = true;
        };
            function date2str2(d) {
            if (d === undefined) {
                return "";
            }
            var month = (d.getMonth() + 1).toString();
            var day = d.getDate().toString();
            if (month.length == 1) month = '0' + month;
            if (day.length == 1) day = '0' + day;
            return d.getFullYear() + "-" + month + "-" + day;
        }


        $scope.date1 = {
             // 'lable': date2str2(new Date()),
            //'value': date2str(new Date()),
            'opened': false
        }


         $scope.dateOpen1 = function ($event, item) {
            $event.preventDefault();
            $event.stopPropagation();
            item.opened = true;
        };
     

         $scope.pageChanged= function () {
          if($scope.date.lable){
                $scope.tour_date=date2str2($scope.date.lable);
            }else{
                $scope.tour_date=''
            }
            if($scope.date1.lable){
                $scope.tour_date_two=date2str2($scope.date1.lable);
            }else{
                $scope.tour_date_two=''
            }
            if($scope.date.lable!=null && $scope.date1.lable!=null){
                if($scope.tour_date>$scope.tour_date_two){
                    alert('开始日期不能大于结束日期');
                    return;
                }
            }
            if($scope.date.lable){
                if(!$scope.date1.lable){
                    alert('开始和结束日期必须同时输入进行搜索')
                    return;
                }
            }
            if($scope.date1.lable){
                if(!$scope.date.lable){
                    alert('开始和结束日期必须同时输入进行搜索')
                    return;
                }
            }

  
    var para = {
        stime :$scope.tour_date,//getDate（）转换为字符：串查询条件开始时间
        etime : $scope.tour_date_two
    };
     para = angular.extend($scope.searchform, para);
    console.log(para)
    console.log('shangmiashi para')
 
$resource('/api/ac/ggc/equipmentUserManageService/findCountInformation', {}, {}).
save(para, function(res){
       //alert("kk");         
        if(res.errcode === 0)
        {
            console.log(res);
            console.log('shangmainshi 返回值')
            $scope.obj = res.data;
            $scope.t1=Number($scope.obj.ScenicUsercount1)+Number($scope.obj.HotelUsercount1);
            $scope.t2=Number($scope.obj.ScenicEquipmentCount1)+Number($scope.obj.HotelEquipmentCount1);
            $scope.t3=Number($scope.obj.ScenicEquipmentFzrCount1)+Number($scope.obj.HotelEquipmentFzrCount1);
            $scope.t4=Number($scope.obj.ScenicEquipmentCheckCount1)+Number($scope.obj.HotelEquipmentCheckCount1);           
            $scope.t5=Number($scope.obj.ScenicEquipmentYqCheckCount1)+Number($scope.obj.HotelEquipmentYqCheckCount1);
            $scope.t6= ($scope.t5/$scope.t4*100+'').substring(0,4)+'%';
             if($scope.t4==0){
                $scope.t6='0%'
            }
            $scope.t7=Number($scope.obj.ScenicEquipmentCheckCount1);
            $scope.t8=Number($scope.obj.ScenicEquipmentYqCheckCount1);
            $scope.t9=($scope.t8/$scope.t7*100+'').substring(0,4)+'%';
             if($scope.t7==0){
                $scope.t9='0%'
            }
            $scope.t10=Number($scope.obj.HotelEquipmentCheckCount1);
            $scope.t11=Number($scope.obj.HotelEquipmentYqCheckCount1);
            $scope.t12=($scope.t11/$scope.t10*100+'').substring(0,4)+'%';
             if($scope.t10==0){
                $scope.t12='0%'
            }
        
        }
        else
        {
            alert(res.errmsg);
        }

               var paras = {
                    pageNo:$scope.currentPage,
                    pageSize:$scope.itemsPerPage
                };
    paras = angular.extend($scope.searchform, paras);
    console.log(paras)
// 风控设备景区信息查询
  $resource('/api/ac/ggc/equipmentManageDetailInformationService/findEquipmentTotalInformationList', {}, {}).
  save(paras, function(res){

            if(res.errcode === 0 || res.errcode === 10003){
                 console.log(res);
                 console.log('上面是列表res')
                 for(var i=0;i<res.data.results.length;i++){
                       if(res.data.results[i].type==3){
                              res.data.results.splice(i, 1);
                        }
                 }
                  $scope.userList=res.data.results;
                  $scope.totalItems = res.data.totalRecord;

            }else{
                alert(res.errmsg);
            }
        });

               var para2 = {
    //    ta:1,
      pageNo:$scope.currentPage,
      pageSize:$scope.itemsPerPage
       
    };
    para2 = angular.extend($scope.searchform, para2);

// 风控设备酒店信息查询
    $resource('/api/ac/ggc/equipmentManageDetailInformationService/findEquipmentHotelTotalInformationList', {}, {}).
  save(para2, function(res){
            if(res.errcode === 0 || res.errcode === 10003){
                 for(var i=0;i<res.data.results.length;i++){
                       if(res.data.results[i].type==3){
                              res.data.results.splice(i, 1);

                        }

                 }
              
                  $scope.userList2=res.data.results;
                  $scope.totalItems2 = res.data.totalRecord;
                   

            }else{
                alert(res.errmsg);
            }
        });

    });

};
$scope.pageChanged();
}